package com.godpaper.as9.commands
{
	import com.adobe.cairngorm.commands.ICommand;
	import com.adobe.cairngorm.control.CairngormEvent;
	import com.adobe.cairngorm.control.CairngormEventDispatcher;
	import com.godpaper.as9.bussiness.delegates.UserDelegate;
	import com.godpaper.as9.events.GetUserInfoEvent;
	import com.godpaper.as9.events.UpdateUserInfoEvent;
	import com.godpaper.as9.model.UserModelLocator;
	
	import mx.rpc.IResponder;

	public class UpdateUserInfoCommand extends CommandBase implements ICommand, IResponder
	{
		private var delegate:UserDelegate;
		private var userModel:UserModelLocator = UserModelLocator.getInstance();
		private var updateUserInfoEvent:UpdateUserInfoEvent;
		public function UpdateUserInfoCommand()
		{
			super();
			delegate = new UserDelegate(this);
		}
		
		override public function execute(event:CairngormEvent):void
		{
			updateUserInfoEvent = UpdateUserInfoEvent(event);
			delegate.update(updateUserInfoEvent.userVO);
		}
		
		override public function result(data:Object):void
		{
			if(data.result.info=="success")
			{
				CairngormEventDispatcher.getInstance().dispatchEvent(new GetUserInfoEvent());
			}
		}
		
	}
}